<template>
  <!-- 雷达图  图表必须给高和宽度-->
  <div ref="myDiv" class="radar-echart" />
</template>

<script>
import * as echarts from 'echarts/core'
import { TitleComponent, LegendComponent } from 'echarts/components'
import { RadarChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'
echarts.use([TitleComponent, LegendComponent, RadarChart, CanvasRenderer])
export default {
  name: 'Radar',
  mounted() {
    this.initEcharts()
  },
  methods: {
    initEcharts() {
      var chartDom = this.$refs.myDiv
      var myChart = echarts.init(chartDom)
      var option

      option = {
        title: {
          text: '基础雷达图'
        },
        legend: {
          data: ['平均水平', '个人价值']
        },
        radar: {
          // shape: 'circle',
          indicator: [
            { name: '工作效率', max: 100 },
            { name: '考勤', max: 100 },
            { name: '积极性', max: 100 },
            { name: '帮助同事', max: 100 },
            { name: '自主学习', max: 100 },
            { name: '正确率', max: 100 }
          ]
        },
        series: [
          {
            name: '平均水平 vs 个人价值',
            type: 'radar',
            data: [
              {
                value: [100, 100, 100, 100, 100, 100],
                name: '个人价值'
              },
              {
                value: [80, 70, 85, 90, 70, 93],
                name: '平均水平'
              }
            ]
          }
        ]
      }

      option && myChart.setOption(option)
    }
  }
}
</script>

<style lang="scss" scoped>
.radar-echart {
  width: 500px;
  height: 400px;
}
</style>
